{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "from sad_network import NeuralNetwork as Network\n",
    "from sad_layer import *\n",
    "from sad_read_mnist import get_mnist\n",
    "(x_train,y_train),(x_test,y_test)=get_mnist()\n",
    "x_train=x_train.reshape(-1,1*28*28)\n",
    "train_data = np.append(x_train, y_train, axis=1)\n",
    "x_test=x_test.reshape(-1,1,28,28)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "def train_and_test(mynetwork,batch_size=32,epoch_num=50):\n",
    "    for i in range(epoch_num):\n",
    "        loss=0\n",
    "        np.random.shuffle(train_data)\n",
    "        print(\"epoch\",i,end=\":\\n\")\n",
    "        for idx_batch in range(train_data.shape[0]//batch_size):\n",
    "            batch_x = train_data[idx_batch*batch_size:(idx_batch+1)*batch_size,:-10].reshape(-1,1,28,28)\n",
    "            batch_y = train_data[idx_batch*batch_size:(idx_batch+1)*batch_size,-10:]\n",
    "            mynetwork.zero_grad()\n",
    "            mynetwork.forward(batch_x)\n",
    "            l=mynetwork.loss(batch_y)\n",
    "            loss+=l\n",
    "            mynetwork.backward()\n",
    "            mynetwork.update(0.01)\n",
    "            print(\"\\r loss:%.9f\"%l,\"\\tprocess:\", int(idx_batch/(train_data.shape[0]//batch_size)*10000)/100,end=\"%\\t   \")\n",
    "        print(\"\\r Loss:%.9f\"%loss,\"\\tAccuracy:\",mynetwork.accuracy(x_test,y_test),\"\\t\\t\") "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "epoch 0:\n",
      " Loss:4311.365902404 \tAccuracy: 0.1138 \t\t\n",
      "epoch 1:\n",
      " Loss:3371.113719322 \tAccuracy: 0.7117 \t\t\n",
      "epoch 2:\n",
      " Loss:1283.198067680 \tAccuracy: 0.8365 \t\t\n",
      "epoch 3:\n",
      " Loss:929.691354005 \tAccuracy: 0.8782 \t\t\n",
      "epoch 4:\n",
      " Loss:744.619752805 \tAccuracy: 0.8967 \t\t\n",
      "epoch 5:\n",
      " Loss:631.141348360 \tAccuracy: 0.9087 \t\t\n",
      "epoch 6:\n",
      " Loss:548.686592272 \tAccuracy: 0.9225 \t\t\n",
      "epoch 7:\n",
      " Loss:480.015443123 \tAccuracy: 0.9337 \t\t\n",
      "epoch 8:\n",
      " Loss:423.446571548 \tAccuracy: 0.9416 \t\t\n",
      "epoch 9:\n",
      " Loss:375.458359487 \tAccuracy: 0.945 \t\t\n",
      "epoch 10:\n",
      " Loss:336.865820376 \tAccuracy: 0.9502 \t\t\n",
      "epoch 11:\n",
      " Loss:306.048235989 \tAccuracy: 0.9547 \t\t\n",
      "epoch 12:\n",
      " Loss:279.362713867 \tAccuracy: 0.9577 \t\t\n",
      "epoch 13:\n",
      " Loss:257.133325063 \tAccuracy: 0.9609 \t\t\n",
      "epoch 14:\n",
      " Loss:237.314460911 \tAccuracy: 0.9638 \t\t\n",
      "epoch 15:\n",
      " Loss:220.245678243 \tAccuracy: 0.9642 \t\t\n",
      "epoch 16:\n",
      " Loss:205.096103827 \tAccuracy: 0.9653 \t\t\n",
      "epoch 17:\n",
      " Loss:192.664968972 \tAccuracy: 0.9685 \t\t\n",
      "epoch 18:\n",
      " Loss:180.779306750 \tAccuracy: 0.9693 \t\t\n",
      "epoch 19:\n",
      " Loss:169.430898482 \tAccuracy: 0.9678 \t\t\n",
      "epoch 20:\n",
      " Loss:160.372079399 \tAccuracy: 0.9679 \t\t\n",
      "epoch 21:\n",
      " Loss:150.571553602 \tAccuracy: 0.9717 \t\t\n",
      "epoch 22:\n",
      " Loss:142.183543813 \tAccuracy: 0.9709 \t\t\n",
      "epoch 23:\n",
      " Loss:134.702170696 \tAccuracy: 0.9714 \t\t\n",
      "epoch 24:\n",
      " Loss:128.133560533 \tAccuracy: 0.972 \t\t\n",
      "epoch 25:\n",
      " Loss:120.924046266 \tAccuracy: 0.9736 \t\t\n",
      "epoch 26:\n",
      " Loss:114.337594338 \tAccuracy: 0.9727 \t\t\n",
      "epoch 27:\n",
      " Loss:109.052528442 \tAccuracy: 0.9726 \t\t\n",
      "epoch 28:\n",
      " Loss:103.726693912 \tAccuracy: 0.9734 \t\t\n",
      "epoch 29:\n",
      " Loss:98.345711646 \tAccuracy: 0.9745 \t\t\n",
      "epoch 30:\n",
      " Loss:93.883939864 \tAccuracy: 0.9746 \t\t\n",
      "epoch 31:\n",
      " Loss:89.115971517 \tAccuracy: 0.9731 \t\t\n",
      "epoch 32:\n",
      " Loss:84.920413169 \tAccuracy: 0.9725 \t\t\n",
      "epoch 33:\n",
      " Loss:81.062667221 \tAccuracy: 0.9748 \t\t\n",
      "epoch 34:\n",
      " Loss:77.511713462 \tAccuracy: 0.9754 \t\t\n",
      "epoch 35:\n",
      " Loss:73.283170660 \tAccuracy: 0.9744 \t\t\n",
      "epoch 36:\n",
      " Loss:69.881093083 \tAccuracy: 0.9749 \t\t\n",
      "epoch 37:\n",
      " Loss:66.321753391 \tAccuracy: 0.9754 \t\t\n",
      "epoch 38:\n",
      " Loss:63.367769554 \tAccuracy: 0.975 \t\t\n",
      "epoch 39:\n",
      " Loss:60.265660609 \tAccuracy: 0.9767 \t\t\n",
      "epoch 40:\n",
      " Loss:57.000054237 \tAccuracy: 0.9758 \t\t\n",
      "epoch 41:\n",
      " Loss:54.688815403 \tAccuracy: 0.9754 \t\t\n",
      "epoch 42:\n",
      " Loss:52.089905430 \tAccuracy: 0.9753 \t\t\n",
      "epoch 43:\n",
      " Loss:49.731067161 \tAccuracy: 0.9752 \t\t\n",
      "epoch 44:\n",
      " Loss:47.108337496 \tAccuracy: 0.9758 \t\t\n",
      "epoch 45:\n",
      " Loss:44.913161185 \tAccuracy: 0.9759 \t\t\n",
      "epoch 46:\n",
      " Loss:42.592361167 \tAccuracy: 0.9766 \t\t\n",
      "epoch 47:\n",
      " Loss:40.456990742 \tAccuracy: 0.9748 \t\t\n",
      "epoch 48:\n",
      " Loss:38.817875882 \tAccuracy: 0.9754 \t\t\n",
      "epoch 49:\n",
      " Loss:36.990737824 \tAccuracy: 0.9769 \t\t\n"
     ]
    }
   ],
   "source": [
    "fc1=[\n",
    "    FullConnectedLayer(784,256),\n",
    "    ReLuLayer(),\n",
    "    FullConnectedLayer(256,64),\n",
    "    ReLuLayer(),\n",
    "    FullConnectedLayer(64,10)\n",
    "]\n",
    "train_and_test(Network(layers=fc1,lossfunction=SoftmaxCrossEntropyLossLayer()))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "epoch 0:\n",
      " Loss:842.289788732 \tAccuracy: 0.3325 \t\t\n",
      "epoch 1:\n",
      " Loss:698.613574754 \tAccuracy: 0.6883 \t\t\n",
      "epoch 2:\n",
      " Loss:390.808048725 \tAccuracy: 0.8375 \t\t\n",
      "epoch 3:\n",
      " Loss:269.820930881 \tAccuracy: 0.8822 \t\t\n",
      "epoch 4:\n",
      " Loss:217.183268791 \tAccuracy: 0.8976 \t\t\n",
      "epoch 5:\n",
      " Loss:190.045518810 \tAccuracy: 0.9051 \t\t\n",
      "epoch 6:\n",
      " Loss:172.937328715 \tAccuracy: 0.9127 \t\t\n",
      "epoch 7:\n",
      " Loss:159.392684631 \tAccuracy: 0.9178 \t\t\n",
      "epoch 8:\n",
      " Loss:147.747777537 \tAccuracy: 0.9239 \t\t\n",
      "epoch 9:\n",
      " Loss:137.646142919 \tAccuracy: 0.9311 \t\t\n",
      "epoch 10:\n",
      " Loss:128.515261635 \tAccuracy: 0.9349 \t\t\n",
      "epoch 11:\n",
      " Loss:120.360884835 \tAccuracy: 0.9393 \t\t\n",
      "epoch 12:\n",
      " Loss:113.005397394 \tAccuracy: 0.9425 \t\t\n",
      "epoch 13:\n",
      " Loss:106.571502182 \tAccuracy: 0.9479 \t\t\n",
      "epoch 14:\n",
      " Loss:100.820035674 \tAccuracy: 0.9502 \t\t\n",
      "epoch 15:\n",
      " Loss:95.652119595 \tAccuracy: 0.9516 \t\t\n",
      "epoch 16:\n",
      " Loss:91.006212472 \tAccuracy: 0.955 \t\t\n",
      "epoch 17:\n",
      " Loss:86.612628768 \tAccuracy: 0.9568 \t\t\n",
      "epoch 18:\n",
      " Loss:82.659762117 \tAccuracy: 0.9588 \t\t\n",
      "epoch 19:\n",
      " Loss:79.066691929 \tAccuracy: 0.9602 \t\t\n",
      "epoch 20:\n",
      " Loss:75.721827346 \tAccuracy: 0.9614 \t\t\n",
      "epoch 21:\n",
      " Loss:72.571296950 \tAccuracy: 0.9623 \t\t\n",
      "epoch 22:\n",
      " Loss:69.790796797 \tAccuracy: 0.9642 \t\t\n",
      "epoch 23:\n",
      " Loss:67.127655406 \tAccuracy: 0.9645 \t\t\n",
      "epoch 24:\n",
      " Loss:64.759912469 \tAccuracy: 0.9658 \t\t\n",
      "epoch 25:\n",
      " Loss:62.523328983 \tAccuracy: 0.9665 \t\t\n",
      "epoch 26:\n",
      " Loss:60.390797537 \tAccuracy: 0.9674 \t\t\n",
      "epoch 27:\n",
      " Loss:58.460395914 \tAccuracy: 0.9688 \t\t\n",
      "epoch 28:\n",
      " Loss:56.619704000 \tAccuracy: 0.969 \t\t\n",
      "epoch 29:\n",
      " Loss:54.918624993 \tAccuracy: 0.9695 \t\t\n",
      "epoch 30:\n",
      " Loss:53.360574993 \tAccuracy: 0.9711 \t\t\n",
      "epoch 31:\n",
      " Loss:51.774700145 \tAccuracy: 0.971 \t\t\n",
      "epoch 32:\n",
      " Loss:50.390050133 \tAccuracy: 0.9723 \t\t\n",
      "epoch 33:\n",
      " Loss:49.032721597 \tAccuracy: 0.973 \t\t\n",
      "epoch 34:\n",
      " Loss:47.737438211 \tAccuracy: 0.9736 \t\t\n",
      "epoch 35:\n",
      " Loss:46.545750071 \tAccuracy: 0.9741 \t\t\n",
      "epoch 36:\n",
      " Loss:45.411537515 \tAccuracy: 0.973 \t\t\n",
      "epoch 37:\n",
      " Loss:44.315993734 \tAccuracy: 0.9747 \t\t\n",
      "epoch 38:\n",
      " Loss:43.336824698 \tAccuracy: 0.9746 \t\t\n",
      "epoch 39:\n",
      " Loss:42.339642698 \tAccuracy: 0.9755 \t\t\n",
      "epoch 40:\n",
      " Loss:41.422700294 \tAccuracy: 0.9758 \t\t\n",
      "epoch 41:\n",
      " Loss:40.544866438 \tAccuracy: 0.9752 \t\t\n",
      "epoch 42:\n",
      " Loss:39.707589553 \tAccuracy: 0.9761 \t\t\n",
      "epoch 43:\n",
      " Loss:38.807897899 \tAccuracy: 0.9765 \t\t\n",
      "epoch 44:\n",
      " Loss:38.074040682 \tAccuracy: 0.9759 \t\t\n",
      "epoch 45:\n",
      " Loss:37.333347666 \tAccuracy: 0.9766 \t\t\n",
      "epoch 46:\n",
      " Loss:36.641089440 \tAccuracy: 0.9768 \t\t\n",
      "epoch 47:\n",
      " Loss:35.912250900 \tAccuracy: 0.9769 \t\t\n",
      "epoch 48:\n",
      " Loss:35.258439833 \tAccuracy: 0.9769 \t\t\n",
      "epoch 49:\n",
      " Loss:34.626832332 \tAccuracy: 0.9774 \t\t\n"
     ]
    }
   ],
   "source": [
    "fc2=[\n",
    "    FullConnectedLayer(784,256),\n",
    "    ReLuLayer(),\n",
    "    FullConnectedLayer(256,64),\n",
    "    ReLuLayer(),\n",
    "    FullConnectedLayer(64,10),\n",
    "    ReLuLayer(),\n",
    "]\n",
    "train_and_test(Network(layers=fc2,lossfunction=MSELossLayer()))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "epoch 0:\n",
      " Loss:4311.184073584 \tAccuracy: 0.1163 \t\t\n",
      "epoch 1:\n",
      " Loss:3340.199534142 \tAccuracy: 0.7402 \t\t\n",
      "epoch 2:\n",
      " Loss:1257.005852822 \tAccuracy: 0.8289 \t\t\n",
      "epoch 3:\n",
      " Loss:942.634391090 \tAccuracy: 0.8804 \t\t\n",
      "epoch 4:\n",
      " Loss:721.576705008 \tAccuracy: 0.8997 \t\t\n",
      "epoch 5:\n",
      " Loss:611.607507238 \tAccuracy: 0.9137 \t\t\n",
      "epoch 6:\n",
      " Loss:538.681739654 \tAccuracy: 0.923 \t\t\n",
      "epoch 7:\n",
      " Loss:477.716615029 \tAccuracy: 0.9332 \t\t\n",
      "epoch 8:\n",
      " Loss:425.987341485 \tAccuracy: 0.9394 \t\t\n",
      "epoch 9:\n",
      " Loss:381.456058534 \tAccuracy: 0.9459 \t\t\n",
      "epoch 10:\n",
      " Loss:343.885723580 \tAccuracy: 0.9506 \t\t\n",
      "epoch 11:\n",
      " Loss:312.190060363 \tAccuracy: 0.9532 \t\t\n",
      "epoch 12:\n",
      " Loss:285.179775924 \tAccuracy: 0.957 \t\t\n",
      "epoch 13:\n",
      " Loss:261.962327379 \tAccuracy: 0.9592 \t\t\n",
      "epoch 14:\n",
      " Loss:241.660853600 \tAccuracy: 0.9616 \t\t\n",
      "epoch 15:\n",
      " Loss:224.451963149 \tAccuracy: 0.964 \t\t\n",
      "epoch 16:\n",
      " Loss:207.945598192 \tAccuracy: 0.965 \t\t\n",
      "epoch 17:\n",
      " Loss:193.567274088 \tAccuracy: 0.9668 \t\t\n",
      "epoch 18:\n",
      " Loss:180.576174804 \tAccuracy: 0.9681 \t\t\n",
      "epoch 19:\n",
      " Loss:169.779193441 \tAccuracy: 0.9678 \t\t\n",
      "epoch 20:\n",
      " Loss:159.351012144 \tAccuracy: 0.9704 \t\t\n",
      "epoch 21:\n",
      " Loss:149.899717424 \tAccuracy: 0.9702 \t\t\n",
      "epoch 22:\n",
      " Loss:141.524618623 \tAccuracy: 0.9721 \t\t\n",
      "epoch 23:\n",
      " Loss:133.597585981 \tAccuracy: 0.9723 \t\t\n",
      "epoch 24:\n",
      " Loss:125.537207185 \tAccuracy: 0.9729 \t\t\n",
      "epoch 25:\n",
      " Loss:118.803170063 \tAccuracy: 0.9727 \t\t\n",
      "epoch 26:\n",
      " Loss:112.607148556 \tAccuracy: 0.9735 \t\t\n",
      "epoch 27:\n",
      " Loss:106.311040152 \tAccuracy: 0.9745 \t\t\n",
      "epoch 28:\n",
      " Loss:101.055571742 \tAccuracy: 0.9749 \t\t\n",
      "epoch 29:\n",
      " Loss:95.856037274 \tAccuracy: 0.9743 \t\t\n",
      "epoch 30:\n",
      " Loss:91.014492060 \tAccuracy: 0.9739 \t\t\n",
      "epoch 31:\n",
      " Loss:86.206022314 \tAccuracy: 0.9747 \t\t\n",
      "epoch 32:\n",
      " Loss:82.281272158 \tAccuracy: 0.9762 \t\t\n",
      "epoch 33:\n",
      " Loss:77.908683904 \tAccuracy: 0.9766 \t\t\n",
      "epoch 34:\n",
      " Loss:73.968529196 \tAccuracy: 0.9753 \t\t\n",
      "epoch 35:\n",
      " Loss:70.269544469 \tAccuracy: 0.9752 \t\t\n",
      "epoch 36:\n",
      " Loss:67.073566969 \tAccuracy: 0.9756 \t\t\n",
      "epoch 37:\n",
      " Loss:63.621331819 \tAccuracy: 0.976 \t\t\n",
      "epoch 38:\n",
      " Loss:60.168355991 \tAccuracy: 0.9763 \t\t\n",
      "epoch 39:\n",
      " Loss:57.567852857 \tAccuracy: 0.9768 \t\t\n",
      "epoch 40:\n",
      " Loss:54.478946768 \tAccuracy: 0.9773 \t\t\n",
      "epoch 41:\n",
      " Loss:52.146277915 \tAccuracy: 0.9764 \t\t\n",
      "epoch 42:\n",
      " Loss:49.304442842 \tAccuracy: 0.9778 \t\t\n",
      "epoch 43:\n",
      " Loss:47.081877472 \tAccuracy: 0.9782 \t\t\n",
      "epoch 44:\n",
      " Loss:44.716672284 \tAccuracy: 0.9781 \t\t\n",
      "epoch 45:\n",
      " Loss:42.382301402 \tAccuracy: 0.9763 \t\t\n",
      "epoch 46:\n",
      " Loss:40.422466304 \tAccuracy: 0.9785 \t\t\n",
      "epoch 47:\n",
      " Loss:38.504906065 \tAccuracy: 0.9777 \t\t\n",
      "epoch 48:\n",
      " Loss:36.673510402 \tAccuracy: 0.9784 \t\t\n",
      "epoch 49:\n",
      " Loss:34.997113274 \tAccuracy: 0.978 \t\t\n"
     ]
    }
   ],
   "source": [
    "fc3=[\n",
    "    FullConnectedLayer(784,256),\n",
    "    LeakyReLULayer(),\n",
    "    FullConnectedLayer(256,64),\n",
    "    LeakyReLULayer(),\n",
    "    FullConnectedLayer(64,10)\n",
    "]\n",
    "train_and_test(Network(layers=fc3,lossfunction=SoftmaxCrossEntropyLossLayer()))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "epoch 0:\n",
      " Loss:4315.480848455 \tAccuracy: 0.1135 \t\t\n",
      "epoch 1:\n",
      " Loss:4314.295932641 \tAccuracy: 0.1135 \t\t\n",
      "epoch 2:\n",
      " Loss:4311.203498006 \tAccuracy: 0.1135 \t\t\n",
      "epoch 3:\n",
      " Loss:4064.501918280 \tAccuracy: 0.3126 \t\t\n",
      "epoch 4:\n",
      " Loss:2858.635128579 \tAccuracy: 0.5268 \t\t\n",
      "epoch 5:\n",
      " Loss:1883.786906284 \tAccuracy: 0.7704 \t\t\n",
      "epoch 6:\n",
      " Loss:1260.096021453 \tAccuracy: 0.8179 \t\t\n",
      "epoch 7:\n",
      " Loss:1056.961707016 \tAccuracy: 0.8493 \t\t\n",
      "epoch 8:\n",
      " Loss:893.056762402 \tAccuracy: 0.8708 \t\t\n",
      "epoch 9:\n",
      " Loss:783.254042076 \tAccuracy: 0.8854 \t\t\n",
      "epoch 10:\n",
      " Loss:711.405976888 \tAccuracy: 0.8945 \t\t\n",
      "epoch 11:\n",
      " Loss:651.140157301 \tAccuracy: 0.9019 \t\t\n",
      "epoch 12:\n",
      " Loss:600.645497488 \tAccuracy: 0.9101 \t\t\n",
      "epoch 13:\n",
      " Loss:556.590658597 \tAccuracy: 0.9173 \t\t\n",
      "epoch 14:\n",
      " Loss:516.891282767 \tAccuracy: 0.9204 \t\t\n",
      "epoch 15:\n",
      " Loss:481.666574216 \tAccuracy: 0.9239 \t\t\n",
      "epoch 16:\n",
      " Loss:449.546695424 \tAccuracy: 0.9311 \t\t\n",
      "epoch 17:\n",
      " Loss:420.435263320 \tAccuracy: 0.9362 \t\t\n",
      "epoch 18:\n",
      " Loss:395.676725645 \tAccuracy: 0.9377 \t\t\n",
      "epoch 19:\n",
      " Loss:373.658468827 \tAccuracy: 0.9407 \t\t\n",
      "epoch 20:\n",
      " Loss:355.228868641 \tAccuracy: 0.9439 \t\t\n",
      "epoch 21:\n",
      " Loss:337.997903560 \tAccuracy: 0.9481 \t\t\n",
      "epoch 22:\n",
      " Loss:322.471139671 \tAccuracy: 0.951 \t\t\n",
      "epoch 23:\n",
      " Loss:308.878669224 \tAccuracy: 0.9518 \t\t\n",
      "epoch 24:\n",
      " Loss:296.127040704 \tAccuracy: 0.9516 \t\t\n",
      "epoch 25:\n",
      " Loss:285.621780840 \tAccuracy: 0.9545 \t\t\n",
      "epoch 26:\n",
      " Loss:275.587178540 \tAccuracy: 0.9564 \t\t\n",
      "epoch 27:\n",
      " Loss:266.568711597 \tAccuracy: 0.9552 \t\t\n",
      "epoch 28:\n",
      " Loss:258.018170116 \tAccuracy: 0.9574 \t\t\n",
      "epoch 29:\n",
      " Loss:251.156799917 \tAccuracy: 0.9563 \t\t\n",
      "epoch 30:\n",
      " Loss:242.943172492 \tAccuracy: 0.9596 \t\t\n",
      "epoch 31:\n",
      " Loss:236.043139794 \tAccuracy: 0.961 \t\t\n",
      "epoch 32:\n",
      " Loss:229.995524860 \tAccuracy: 0.9601 \t\t\n",
      "epoch 33:\n",
      " Loss:223.902826469 \tAccuracy: 0.9618 \t\t\n",
      "epoch 34:\n",
      " Loss:218.630524933 \tAccuracy: 0.9615 \t\t\n",
      "epoch 35:\n",
      " Loss:212.392631828 \tAccuracy: 0.9626 \t\t\n",
      "epoch 36:\n",
      " Loss:207.899214414 \tAccuracy: 0.9612 \t\t\n",
      "epoch 37:\n",
      " Loss:203.434247664 \tAccuracy: 0.962 \t\t\n",
      "epoch 38:\n",
      " Loss:198.878849183 \tAccuracy: 0.9625 \t\t\n",
      "epoch 39:\n",
      " Loss:194.129228009 \tAccuracy: 0.9618 \t\t\n",
      "epoch 40:\n",
      " Loss:190.239975907 \tAccuracy: 0.963 \t\t\n",
      "epoch 41:\n",
      " Loss:186.388159552 \tAccuracy: 0.9641 \t\t\n",
      "epoch 42:\n",
      " Loss:183.034263533 \tAccuracy: 0.9647 \t\t\n",
      "epoch 43:\n",
      " Loss:179.211625452 \tAccuracy: 0.9654 \t\t\n",
      "epoch 44:\n",
      " Loss:175.549827555 \tAccuracy: 0.9661 \t\t\n",
      "epoch 45:\n",
      " Loss:172.012326377 \tAccuracy: 0.9647 \t\t\n",
      "epoch 46:\n",
      " Loss:168.599030050 \tAccuracy: 0.9637 \t\t\n",
      "epoch 47:\n",
      " Loss:166.069115909 \tAccuracy: 0.9661 \t\t\n",
      "epoch 48:\n",
      " Loss:162.296123944 \tAccuracy: 0.9659 \t\t\n",
      "epoch 49:\n",
      " Loss:159.288111427 \tAccuracy: 0.9658 \t\t\n"
     ]
    }
   ],
   "source": [
    "fcd=[\n",
    "    MaxPooling2DLayer(2,2),\n",
    "    FullConnectedLayer(14*14,64),\n",
    "    ReLuLayer(),\n",
    "    FullConnectedLayer(64,32),\n",
    "    ReLuLayer(),\n",
    "    FullConnectedLayer(32,10)\n",
    "]\n",
    "train_and_test(Network(layers=fcd,lossfunction=SoftmaxCrossEntropyLossLayer()))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "epoch 0:\n",
      " Loss:4315.597490719 \tAccuracy: 0.1135 \t\t\n",
      "epoch 1:\n",
      " Loss:4314.915597228 \tAccuracy: 0.1135 \t\t\n",
      "epoch 2:\n",
      " Loss:4314.841628810 \tAccuracy: 0.1135 \t\t\n",
      "epoch 3:\n",
      " Loss:4314.883170365 \tAccuracy: 0.1135 \t\t\n",
      "epoch 4:\n",
      " Loss:4314.831936800 \tAccuracy: 0.1135 \t\t\n",
      "epoch 5:\n",
      " Loss:4314.916906715 \tAccuracy: 0.1135 \t\t\n",
      "epoch 6:\n",
      " Loss:4314.892627007 \tAccuracy: 0.1135 \t\t\n",
      "epoch 7:\n",
      " Loss:4314.881847345 \tAccuracy: 0.1135 \t\t\n",
      "epoch 8:\n",
      " Loss:4314.882305783 \tAccuracy: 0.1135 \t\t\n",
      "epoch 9:\n",
      " Loss:4314.865864738 \tAccuracy: 0.1135 \t\t\n",
      "epoch 10:\n",
      " Loss:4314.876928444 \tAccuracy: 0.1135 \t\t\n",
      "epoch 11:\n",
      " Loss:4314.866804228 \tAccuracy: 0.1135 \t\t\n",
      "epoch 12:\n",
      " Loss:4314.886303630 \tAccuracy: 0.1135 \t\t\n",
      "epoch 13:\n",
      " Loss:4314.851915567 \tAccuracy: 0.1135 \t\t\n",
      "epoch 14:\n",
      " Loss:4314.877548735 \tAccuracy: 0.1135 \t\t\n",
      "epoch 15:\n",
      " Loss:4314.861024941 \tAccuracy: 0.1135 \t\t\n",
      "epoch 16:\n",
      " Loss:4314.843627608 \tAccuracy: 0.1135 \t\t\n",
      "epoch 17:\n",
      " Loss:4314.835994949 \tAccuracy: 0.1135 \t\t\n",
      "epoch 18:\n",
      " Loss:4314.789164592 \tAccuracy: 0.1135 \t\t\n",
      "epoch 19:\n",
      " Loss:4314.649598002 \tAccuracy: 0.1135 \t\t\n",
      "epoch 20:\n",
      " Loss:4314.415406342 \tAccuracy: 0.1135 \t\t\n",
      "epoch 21:\n",
      " Loss:4312.739163646 \tAccuracy: 0.1135 \t\t\n",
      "epoch 22:\n",
      " Loss:3699.865039129 \tAccuracy: 0.629 \t\t\n",
      "epoch 23:\n",
      " Loss:1209.215741482 \tAccuracy: 0.8787 \t\t\n",
      "epoch 24:\n",
      " Loss:695.108151727 \tAccuracy: 0.9158 \t\t\n",
      "epoch 25:\n",
      " Loss:522.542568020 \tAccuracy: 0.9269 \t\t\n",
      "epoch 26:\n",
      " Loss:418.761497083 \tAccuracy: 0.9427 \t\t\n",
      "epoch 27:\n",
      " Loss:352.642337709 \tAccuracy: 0.9483 \t\t\n",
      "epoch 28:\n",
      " Loss:308.386651261 \tAccuracy: 0.9557 \t\t\n",
      "epoch 29:\n",
      " Loss:278.736904378 \tAccuracy: 0.9499 \t\t\n",
      "epoch 30:\n",
      " Loss:255.246207113 \tAccuracy: 0.9618 \t\t\n",
      "epoch 31:\n",
      " Loss:235.360728002 \tAccuracy: 0.9616 \t\t\n",
      "epoch 32:\n",
      " Loss:221.801553656 \tAccuracy: 0.9669 \t\t\n",
      "epoch 33:\n",
      " Loss:209.937925102 \tAccuracy: 0.9647 \t\t\n",
      "epoch 34:\n",
      " Loss:199.556387882 \tAccuracy: 0.9669 \t\t\n",
      "epoch 35:\n",
      " Loss:192.877205351 \tAccuracy: 0.9642 \t\t\n",
      "epoch 36:\n",
      " Loss:184.764197036 \tAccuracy: 0.969 \t\t\n",
      "epoch 37:\n",
      " Loss:177.164053709 \tAccuracy: 0.9653 \t\t\n",
      "epoch 38:\n",
      " Loss:170.685862197 \tAccuracy: 0.9676 \t\t\n",
      "epoch 39:\n",
      " Loss:165.091709532 \tAccuracy: 0.97 \t\t\n",
      "epoch 40:\n",
      " Loss:160.675939665 \tAccuracy: 0.9708 \t\t\n",
      "epoch 41:\n",
      " Loss:154.735875228 \tAccuracy: 0.9708 \t\t\n",
      "epoch 42:\n",
      " Loss:150.817517746 \tAccuracy: 0.9681 \t\t\n",
      "epoch 43:\n",
      " Loss:147.736939319 \tAccuracy: 0.9682 \t\t\n",
      "epoch 44:\n",
      " Loss:143.005091000 \tAccuracy: 0.9696 \t\t\n",
      "epoch 45:\n",
      " Loss:136.517753590 \tAccuracy: 0.9713 \t\t\n",
      "epoch 46:\n",
      " Loss:134.055164729 \tAccuracy: 0.9687 \t\t\n",
      "epoch 47:\n",
      " Loss:130.882483612 \tAccuracy: 0.9711 \t\t\n",
      "epoch 48:\n",
      " Loss:128.771630362 \tAccuracy: 0.968 \t\t\n",
      "epoch 49:\n",
      " Loss:126.029729213 \tAccuracy: 0.9685 \t\t\n"
     ]
    }
   ],
   "source": [
    "con3fc=[\n",
    "    Conv2DLayer(1,3,3,0),\n",
    "    ReLuLayer(),\n",
    "    FullConnectedLayer(3*26*26,32),\n",
    "    ReLuLayer(),\n",
    "    FullConnectedLayer(32,20),\n",
    "    ReLuLayer(),\n",
    "    FullConnectedLayer(20,10)\n",
    "]\n",
    "train_and_test(Network(con3fc))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "epoch 0:\n",
      " Loss:4315.536506875 \tAccuracy: 0.1135 \t\t\n",
      "epoch 1:\n",
      " Loss:4314.875207739 \tAccuracy: 0.1135 \t\t\n",
      "epoch 2:\n",
      " Loss:4314.870109803 \tAccuracy: 0.1135 \t\t\n",
      "epoch 3:\n",
      " Loss:4314.905224139 \tAccuracy: 0.1135 \t\t\n",
      "epoch 4:\n",
      " Loss:4314.860400099 \tAccuracy: 0.1135 \t\t\n",
      "epoch 5:\n",
      " Loss:4314.901679583 \tAccuracy: 0.1135 \t\t\n",
      "epoch 6:\n",
      " Loss:4314.878001019 \tAccuracy: 0.1135 \t\t\n",
      "epoch 7:\n",
      " Loss:4314.898111121 \tAccuracy: 0.1135 \t\t\n",
      "epoch 8:\n",
      " Loss:4314.892404278 \tAccuracy: 0.1135 \t\t\n",
      "epoch 9:\n",
      " Loss:4314.889558286 \tAccuracy: 0.1135 \t\t\n",
      "epoch 10:\n",
      " Loss:4314.899013620 \tAccuracy: 0.1135 \t\t\n",
      "epoch 11:\n",
      " Loss:4314.873864347 \tAccuracy: 0.1135 \t\t\n",
      "epoch 12:\n",
      " Loss:4314.885227421 \tAccuracy: 0.1135 \t\t\n",
      "epoch 13:\n",
      " Loss:4314.898466815 \tAccuracy: 0.1135 \t\t\n",
      "epoch 14:\n",
      " Loss:4314.853217576 \tAccuracy: 0.1135 \t\t\n",
      "epoch 15:\n",
      " Loss:4314.862058671 \tAccuracy: 0.1135 \t\t\n",
      "epoch 16:\n",
      " Loss:4314.901493630 \tAccuracy: 0.1135 \t\t\n",
      "epoch 17:\n",
      " Loss:4314.862163509 \tAccuracy: 0.1135 \t\t\n",
      "epoch 18:\n",
      " Loss:4314.880878304 \tAccuracy: 0.1135 \t\t\n",
      "epoch 19:\n",
      " Loss:4314.881289726 \tAccuracy: 0.1135 \t\t\n",
      "epoch 20:\n",
      " Loss:4314.904980572 \tAccuracy: 0.1135 \t\t\n",
      "epoch 21:\n",
      " Loss:4314.879861595 \tAccuracy: 0.1135 \t\t\n",
      "epoch 22:\n",
      " Loss:4314.882937844 \tAccuracy: 0.1135 \t\t\n",
      "epoch 23:\n",
      " Loss:4314.893649847 \tAccuracy: 0.1135 \t\t\n",
      "epoch 24:\n",
      " Loss:4314.891714461 \tAccuracy: 0.1135 \t\t\n",
      "epoch 25:\n",
      " Loss:4314.868460291 \tAccuracy: 0.1135 \t\t\n",
      "epoch 26:\n",
      " Loss:4314.868069692 \tAccuracy: 0.1135 \t\t\n",
      "epoch 27:\n",
      " Loss:4314.893539991 \tAccuracy: 0.1135 \t\t\n",
      "epoch 28:\n",
      " Loss:4314.908170934 \tAccuracy: 0.1135 \t\t\n",
      "epoch 29:\n",
      " Loss:4314.885153027 \tAccuracy: 0.1135 \t\t\n",
      "epoch 30:\n",
      " Loss:4314.840049159 \tAccuracy: 0.1135 \t\t\n",
      "epoch 31:\n",
      " Loss:4314.908526754 \tAccuracy: 0.1135 \t\t\n",
      "epoch 32:\n",
      " Loss:4314.881195242 \tAccuracy: 0.1135 \t\t\n",
      "epoch 33:\n",
      " Loss:4314.876947446 \tAccuracy: 0.1135 \t\t\n",
      "epoch 34:\n",
      " Loss:4314.891674137 \tAccuracy: 0.1135 \t\t\n",
      "epoch 35:\n",
      " Loss:4314.869799342 \tAccuracy: 0.1135 \t\t\n",
      "epoch 36:\n",
      " Loss:4314.877286418 \tAccuracy: 0.1135 \t\t\n",
      "epoch 37:\n",
      " Loss:4314.886226756 \tAccuracy: 0.1135 \t\t\n",
      "epoch 38:\n",
      " Loss:4314.877937229 \tAccuracy: 0.1135 \t\t\n",
      "epoch 39:\n",
      " Loss:4314.853797623 \tAccuracy: 0.1135 \t\t\n",
      "epoch 40:\n",
      " Loss:4314.898224011 \tAccuracy: 0.1135 \t\t\n",
      "epoch 41:\n",
      " Loss:4314.874135396 \tAccuracy: 0.1135 \t\t\n",
      "epoch 42:\n",
      " Loss:4314.891691908 \tAccuracy: 0.1135 \t\t\n",
      "epoch 43:\n",
      " Loss:4314.870460163 \tAccuracy: 0.1135 \t\t\n",
      "epoch 44:\n",
      " Loss:4314.867265108 \tAccuracy: 0.1135 \t\t\n",
      "epoch 45:\n",
      " Loss:4314.883469966 \tAccuracy: 0.1135 \t\t\n",
      "epoch 46:\n",
      " Loss:4314.891918463 \tAccuracy: 0.1135 \t\t\n",
      "epoch 47:\n",
      " Loss:4314.886714677 \tAccuracy: 0.1135 \t\t\n",
      "epoch 48:\n",
      " Loss:4314.871268767 \tAccuracy: 0.1135 \t\t\n",
      "epoch 49:\n",
      " Loss:4314.889368427 \tAccuracy: 0.1135 \t\t\n"
     ]
    }
   ],
   "source": [
    "con2fc2=[\n",
    "    Conv2DLayer(1,16,3,0),\n",
    "    ReLuLayer(),\n",
    "    MaxPooling2DLayer(4,4),\n",
    "    Conv2DLayer(16,32,3,0),\n",
    "    ReLuLayer(),\n",
    "    MaxPooling2DLayer(4,4),\n",
    "    FullConnectedLayer(32,20),\n",
    "    ReLuLayer(),\n",
    "    FullConnectedLayer(20,10)\n",
    "]\n",
    "train_and_test(Network(con2fc2))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "epoch 0:\n",
      " loss:2.295655884 \tprocess: 91.52%\t   "
     ]
    },
    {
     "ename": "KeyboardInterrupt",
     "evalue": "",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mKeyboardInterrupt\u001b[0m                         Traceback (most recent call last)",
      "Cell \u001b[1;32mIn[18], line 12\u001b[0m\n\u001b[0;32m      1\u001b[0m con3fc\u001b[38;5;241m=\u001b[39m[\n\u001b[0;32m      2\u001b[0m     Conv2DLayer(\u001b[38;5;241m1\u001b[39m,\u001b[38;5;241m16\u001b[39m,\u001b[38;5;241m3\u001b[39m,\u001b[38;5;241m0\u001b[39m),\n\u001b[0;32m      3\u001b[0m     LeakyReLULayer(),\n\u001b[1;32m   (...)\u001b[0m\n\u001b[0;32m     10\u001b[0m     FullConnectedLayer(\u001b[38;5;241m20\u001b[39m,\u001b[38;5;241m10\u001b[39m)\n\u001b[0;32m     11\u001b[0m ]\n\u001b[1;32m---> 12\u001b[0m train_and_test(Network(con3fc))\n",
      "Cell \u001b[1;32mIn[11], line 10\u001b[0m, in \u001b[0;36mtrain_and_test\u001b[1;34m(mynetwork, batch_size, epoch_num)\u001b[0m\n\u001b[0;32m      8\u001b[0m batch_y \u001b[38;5;241m=\u001b[39m train_data[idx_batch\u001b[38;5;241m*\u001b[39mbatch_size:(idx_batch\u001b[38;5;241m+\u001b[39m\u001b[38;5;241m1\u001b[39m)\u001b[38;5;241m*\u001b[39mbatch_size,\u001b[38;5;241m-\u001b[39m\u001b[38;5;241m10\u001b[39m:]\n\u001b[0;32m      9\u001b[0m mynetwork\u001b[38;5;241m.\u001b[39mzero_grad()\n\u001b[1;32m---> 10\u001b[0m mynetwork\u001b[38;5;241m.\u001b[39mforward(batch_x)\n\u001b[0;32m     11\u001b[0m l\u001b[38;5;241m=\u001b[39mmynetwork\u001b[38;5;241m.\u001b[39mloss(batch_y)\n\u001b[0;32m     12\u001b[0m loss\u001b[38;5;241m+\u001b[39m\u001b[38;5;241m=\u001b[39ml\n",
      "File \u001b[1;32md:\\Users\\Fox\\桌面\\sad_machine_learning\\sad_network.py:22\u001b[0m, in \u001b[0;36mNeuralNetwork.forward\u001b[1;34m(self, input)\u001b[0m\n\u001b[0;32m     20\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mforward\u001b[39m(\u001b[38;5;28mself\u001b[39m,\u001b[38;5;28minput\u001b[39m):\n\u001b[0;32m     21\u001b[0m     \u001b[38;5;28;01mfor\u001b[39;00m layer \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mlayers:\n\u001b[1;32m---> 22\u001b[0m         \u001b[38;5;28minput\u001b[39m\u001b[38;5;241m=\u001b[39mlayer\u001b[38;5;241m.\u001b[39mforward(\u001b[38;5;28minput\u001b[39m)\n\u001b[0;32m     23\u001b[0m     \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mlossfunction\u001b[38;5;241m.\u001b[39mforward(\u001b[38;5;28minput\u001b[39m)\n",
      "File \u001b[1;32md:\\Users\\Fox\\桌面\\sad_machine_learning\\sad_layer.py:170\u001b[0m, in \u001b[0;36mConv2DLayer.forward\u001b[1;34m(self, input_data)\u001b[0m\n\u001b[0;32m    168\u001b[0m out_h\u001b[38;5;241m=\u001b[39m(h\u001b[38;5;241m+\u001b[39m\u001b[38;5;241m2\u001b[39m\u001b[38;5;241m*\u001b[39m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mpadding\u001b[38;5;241m-\u001b[39m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mkernel_size[\u001b[38;5;241m0\u001b[39m])\u001b[38;5;241m/\u001b[39m\u001b[38;5;241m/\u001b[39m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mstride[\u001b[38;5;241m0\u001b[39m]\u001b[38;5;241m+\u001b[39m\u001b[38;5;241m1\u001b[39m\n\u001b[0;32m    169\u001b[0m out_w\u001b[38;5;241m=\u001b[39m(w\u001b[38;5;241m+\u001b[39m\u001b[38;5;241m2\u001b[39m\u001b[38;5;241m*\u001b[39m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mpadding\u001b[38;5;241m-\u001b[39m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mkernel_size[\u001b[38;5;241m1\u001b[39m])\u001b[38;5;241m/\u001b[39m\u001b[38;5;241m/\u001b[39m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mstride[\u001b[38;5;241m1\u001b[39m]\u001b[38;5;241m+\u001b[39m\u001b[38;5;241m1\u001b[39m\n\u001b[1;32m--> 170\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mcol\u001b[38;5;241m=\u001b[39mim2col(input_data,\u001b[38;5;241m*\u001b[39m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mkernel_size,\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mstride,\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mpadding)\n\u001b[0;32m    171\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39moutput_data\u001b[38;5;241m=\u001b[39m(np\u001b[38;5;241m.\u001b[39mdot(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mcol,\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mw\u001b[38;5;241m.\u001b[39mreshape(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39moutput_channels,\u001b[38;5;241m-\u001b[39m\u001b[38;5;241m1\u001b[39m)\u001b[38;5;241m.\u001b[39mT)\u001b[38;5;241m+\u001b[39m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mb)\u001b[38;5;241m.\u001b[39mreshape(batch_size,out_h,out_w,\u001b[38;5;241m-\u001b[39m\u001b[38;5;241m1\u001b[39m)\u001b[38;5;241m.\u001b[39mtranspose(\u001b[38;5;241m0\u001b[39m,\u001b[38;5;241m3\u001b[39m,\u001b[38;5;241m1\u001b[39m,\u001b[38;5;241m2\u001b[39m)\n\u001b[0;32m    172\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39moutput_data\n",
      "File \u001b[1;32md:\\Users\\Fox\\桌面\\sad_machine_learning\\sad_layer.py:26\u001b[0m, in \u001b[0;36mim2col\u001b[1;34m(input_data, filter_h, filter_w, stride, pad)\u001b[0m\n\u001b[0;32m     24\u001b[0m         col[:, :, y, x, :, :] \u001b[38;5;241m=\u001b[39m img[:, :, y:y_max:stride_h, x:x_max:stride_w]\n\u001b[0;32m     25\u001b[0m \u001b[38;5;66;03m# 塑造为列矩阵\u001b[39;00m\n\u001b[1;32m---> 26\u001b[0m col \u001b[38;5;241m=\u001b[39m col\u001b[38;5;241m.\u001b[39mtranspose(\u001b[38;5;241m0\u001b[39m, \u001b[38;5;241m4\u001b[39m, \u001b[38;5;241m5\u001b[39m, \u001b[38;5;241m1\u001b[39m, \u001b[38;5;241m2\u001b[39m, \u001b[38;5;241m3\u001b[39m)\u001b[38;5;241m.\u001b[39mreshape(N\u001b[38;5;241m*\u001b[39mout_h\u001b[38;5;241m*\u001b[39mout_w, \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m1\u001b[39m)\n\u001b[0;32m     27\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m col\n",
      "\u001b[1;31mKeyboardInterrupt\u001b[0m: "
     ]
    }
   ],
   "source": [
    "con2fc1=[\n",
    "    Conv2DLayer(1,16,3,0),\n",
    "    LeakyReLULayer(),\n",
    "    MaxPooling2DLayer(4,4),\n",
    "    Conv2DLayer(16,32,3,0),\n",
    "    LeakyReLULayer(),\n",
    "    MaxPooling2DLayer(4,4),\n",
    "    FullConnectedLayer(32,10)\n",
    "]\n",
    "train_and_test(Network(con2fc1))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "face",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
